<!--
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2023-12-25 11:50:21
 * @LastEditors: sueRimn
 * @LastEditTime: 2024-01-17 14:03:38
-->
<template>
  <div>
    <el-dialog
      title="审核"
      width="480px"
      :visible.sync="dialogshow"
      :before-close="handleClose"
      :close-on-click-modal="false"

    >
      <div class="dialogBody">
        <el-form
          :model="form"
          class="demo-form-inline"
          size="small"
          label-width="90px"
        >
          <el-form-item label="审核意见：">
            <el-radio-group v-model="form.status">
              <el-radio :label="2">通过</el-radio>
              <el-radio :label="3">不通过</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="审核意见：">
            <el-input
              style="width: 920px"
              type="textarea"
              v-model="form.remarks"
              :autosize="{ minRows: 4 }"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="confirmHandle">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { talentReview, TalentActivityReview } from "@/api/talent.js";
export default {
  name: "",
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    id: "",
    flag: {
      type: Number,
      default: 1,
    },
  },
  data() {
    return {
      dialogshow: this.dialogVisible,
      form: {
        status: 2,
        remarks: "",
      },
    };
  },
  // 在Vue组件中

  created() {
    // this.$watch(
    //   "dialogshow",
    //   (newValue, oldValue) => {
    //     console.log("data changed:", newValue);
    //   },
    //   { deep: true }
    // );
  },
  components: {},

  computed: {},

  beforeMount() {},

  mounted() {
    // console.log(this.id, "idididididididi=====");
  },

  methods: {
    handleClose() {
      if (this.flag == 2) {
        this.$emit("handleClose", 1);
      }
      if (this.flag == 4) {
        this.$emit("handleClose", 2);
      }
    },
    confirmHandle() {
      if (this.flag == 2) {
        TalentActivityReview({
          id: this.id,
          status: this.form.status,
          review_content: this.form.remarks,
        }).then((res) => {
          if (res.code == 200) {
            this.$message({
              type: "success",
              message: "审核成功",
            });
            this.handleClose();
            // this.$emit("handleClose", 1);
          }
        });
      }
      if (this.flag == 4) {
        talentReview({
          id: this.id,
          status: this.form.status,
          review_remark: this.form.remarks,
        }).then((res) => {
          if (res.code == 200) {
            this.$message({
              type: "success",
              message: "审核成功",
            });
            this.handleClose();

            // this.$emit("handleClose", 2);
          }
          //  else {
          //   this.$message({
          //     type: "error",
          //     message: res.msg,
          //   });
          // }
        });
      }
    },
  },

  watch: {
    dialogshow: {
      handler(newv, oldv) {
        console.log(newv, "888888newnewnewnwe");
        this.dialogshow = newv;
      },
      deep: true,
    },
  },
};
</script>
<style lang="scss" scoped>
.dialogBody {
  /deep/.el-textarea__inner {
    width: 350px;
  }
}
</style>
